import { ref } from 'vue'

export function useForm() {
    const state = {
        groupCode: '',
        groupName: '',
        groupPath: '',
        sort: 0,
    }
    const schema: PlusColumn[] = [
        {
            colProps: {
                span: 6,
            },
            label: '应用名称',
            prop: 'menuName',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 8,
            },
            fieldProps: {
                endPlaceholder: '请选择结束时间',
                format: 'YYYY-MM-DD',
                startPlaceholder: '请选择开始时间',
                type: 'datetimerange',
                valueFormat: 'YYYY-MM-DD',
            },
            label: '到期时间',
            prop: 'updateTime',
            valueType: 'date-picker',
        },
        {
            colProps: {
                span: 6,
            },
            label: '应用状态',
            options: status,
            prop: 'status',
            valueType: 'select',
        },
    ] as const

    const rules = reactive<any>({
        groupCode: [
            { message: '请输入', required: true, trigger: 'blur' },
        ],
        groupName: [
            { message: '请输入', required: true, trigger: 'blur' },
        ],
        groupPath: [
            { message: '请输入', required: true, trigger: 'blur' },
        ],
    })

    const formRef = ref()

    return { formRef, rules, schema, state }
}
